package com.yand.thinkingInJava.thinkingInJava21;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class SleepingTask extends ListOff {


    @Override
    public void run() {
        try {
            while(countDown-- > 0){
                System.out.print(status());


                //用这个方法进行睡眠，语义比较好 ， 放入 TimeUnit 中
                TimeUnit.MILLISECONDS.sleep(1000);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


    public static void main(String [] args){
        ExecutorService exec =  Executors.newCachedThreadPool();

        for(int i = 0 ; i < 5 ; i ++){
            exec.execute(new SleepingTask());
        }

        exec.shutdown();


    }










}
